Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: Support some definitions and fix a bug to modify|change column #2629

Merged
merged 3 commits into from
Feb 13, 2017

Conversation

zimulala
Copy link
Contributor

This PR for the statement of alter table ... modify|change column.
Support the following definitions: 'not null', 'null', 'default value' and 'comment'.
Fix the same type of change.

@@ -846,6 +846,10 @@ func modifiable(origin *types.FieldType, to *types.FieldType) bool {
return false
}
default:
if origin.Tp == to.Tp {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check Flen, Decimal and Flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are checked in line819-830.

if err != nil {
return errors.Trace(err)
return ErrColumnBadNull.Gen("invalid default value - %s", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test case for this case.

ddl/ddl_api.go Outdated
col.Flag &= ^uint(mysql.NotNullFlag)
case ast.ColumnOptionOnUpdate:
if !expression.IsCurrentTimeExpr(opt.Expr) {
return ErrInvalidOnUpdate.Gen("invalid ON UPDATE for - %s", col.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test case for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is done at the parsing layer In MySQL. But we didn't do that. I will fix it in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now we only support the type of current_timestamp. I will add a TODO here.

@coocood
Copy link
Member

coocood commented Feb 13, 2017

LGTM

@zimulala
Copy link
Contributor Author

PTAL @shenli

@shenli
Copy link
Member

shenli commented Feb 13, 2017

LGTM

@zimulala zimulala merged commit 05413a4 into master Feb 13, 2017
@zimulala zimulala deleted the zimuxia/modify-definition branch February 13, 2017 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants